package com.ctshk.sapp.system.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.rpc.system.dto.mian.data.MainDataNotGroupRulesDTO;
import com.ctshk.rpc.system.dto.mian.data.MainDataTravelTipsDTO;
import com.ctshk.rpc.system.req.main.data.*;
import com.ctshk.rpc.system.service.IMainDataNotGroupRulesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;

/**
 * <p>
 * 不成团退费规则 前端控制器
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-01-26
 */
@Api(value = "不成团退费规则", tags = "不成团退费规则")
@RestController
@RequestMapping("/main/data/not/group/rules")
public class MainDataNotGroupRulesController extends BaseController {


    @DubboReference
    private IMainDataNotGroupRulesService mainDataNotGroupRulesService;

    @ApiOperation(value = "新增不成团规则", notes = "新增不成团规则")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.ADD, operTitle = "新增不成团规则", operDesc = "新增不成团规则")
    @PostMapping("/add")
    public Result add(@RequestBody @Valid MainDataNotGroupRulesReq req) {
        return mainDataNotGroupRulesService.add(req, getCurrentUser(getRequest()));
    }

    @ApiOperation(value = "编辑不成团规则", notes = "编辑不成团规则")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "编辑不成团规则", operDesc = "编辑不成团规则")
    @PostMapping("/update")
    public Result update(@RequestBody @Valid MainDataNotGroupRulesUpdateReq req) {
        return mainDataNotGroupRulesService.update(req, getCurrentUser(getRequest()));
    }


    @ApiOperation(value = "删除不成团规则", notes = "删除不成团规则")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.DELETE, operTitle = "删除不成团规则", operDesc = "删除不成团规则")
    @PostMapping("/delete")
    public Result delete(@RequestBody @Valid MainDataNotGroupRulesIdReq req) {
        mainDataNotGroupRulesService.delete(req, getCurrentUser(getRequest()));
        return Result.success();
    }


    @ApiOperation(value = "查询不成团规则列表", notes = "查询不成团规则列表")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查询不成团规则列表", operDesc = "查询不成团规则列表")
    @PostMapping("/queryList")
    public Result<PageResponse<MainDataNotGroupRulesDTO>> queryList(@RequestBody @Valid MainDataNotGroupRulesQueryReq mainDataNotGroupRulesQueryReq) {
        return Result.success(mainDataNotGroupRulesService.queryList(mainDataNotGroupRulesQueryReq));
    }


    @ApiOperation(value="设置状态接口（有效，无效）", notes="设置状态接口（有效，无效）")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "设置状态接口（有效，无效）", operDesc = "设置状态接口（有效，无效）")
    @PostMapping("/update/status")
    public Result updateStatus(@RequestBody @Valid MainDataNotGroupRulesIdReq mainDataNotGroupRulesIdReq) {
        mainDataNotGroupRulesService.updateStatus(mainDataNotGroupRulesIdReq,getCurrentUser(getRequest()));
        return Result.success();
    }

    @ApiOperation(value = "查询不成团规则", notes = "查询不成团规则")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查询不成团规则", operDesc = "查询不成团规则")
    @PostMapping("/query")
    public Result<MainDataNotGroupRulesDTO> query(@RequestBody @Valid MainDataNotGroupRulesIdReq req) {
        return Result.success(mainDataNotGroupRulesService.query(req));
    }

}
